package net.pws.common.security.spi.resource;

import java.util.ArrayList;
import java.util.List;

public class Resource implements IResource {
    
    private String id;
    
    private String code;
    
    private String name;
    
    private String type;
    
    private String url;
    
    private String description;
    
    private int depth;
    
    private Resource parent;
    
    private List<Resource> children = new ArrayList<Resource>();
    
    private boolean leaf;
    
    private boolean forbidden = true;
    
    public String getId() {
        return id;
    }
    
    public void setId(String id) {
        this.id = id;
    }
    
    public String getCode() {
        return code;
    }
    
    public void setCode(String code) {
        this.code = code;
    }
    
    public String getName() {
        return name;
    }
    
    public void setName(String name) {
        this.name = name;
    }
    
    public String getType() {
        return type;
    }
    
    public void setType(String type) {
        this.type = type;
    }
    
    public String getUrl() {
        return url;
    }
    
    public void setUrl(String url) {
        this.url = url;
    }
    
    public String getDescription() {
        return description;
    }
    
    public void setDescription(String description) {
        this.description = description;
    }
    
    public int getDepth() {
        return depth;
    }
    
    public void setDepth(int depth) {
        this.depth = depth;
    }
    
    public Resource getParent() {
        return parent;
    }
    
    public void setParent(Resource parent) {
        this.parent = parent;
    }
    
    public List<Resource> getChildren() {
        return children;
    }
    
    public void addChild(Resource resource) {
        if (null == resource) {
            children = new ArrayList<Resource>();
        }
        
        children.add(resource);
        resource.setParent(this);
    }
    
    public void setChildren(List<Resource> children) {
        this.children = children;
    }
    
    public boolean isLeaf() {
        return leaf;
    }
    
    public void setLeaf(boolean leaf) {
        this.leaf = leaf;
    }
    
    public void setForbidden(boolean forbidden) {
        this.forbidden = forbidden;
    }
    
    public boolean isForbidden() {
        return this.forbidden;
    }
    
}
